﻿using Clothes.Comment;
using Clothes.IBLL;
using Clothes.IDAL;
using Clothes.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Clothes.DAL;

namespace Clothes.BLL
{
    /// <summary>
    /// 用户信息业务管理类
    /// </summary>
    public class UserManager : IUserManager
    {
        public OperResult<CLUser> EditAvatar(CLUser user)
        {
            IUserService userService = new UserService();
            try
            {
                CLUser profileEntity = userService.EditAvatar(user);
                return OperResult<CLUser>.Success(profileEntity);
            }
            catch (Exception ex)
            {
                return OperResult<CLUser>.Wrong(ex);
            }
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        public OperResult<CLUser> EditWithoutAvatar(CLUser user)
        {

            IUserService userService = new UserService();
            try
            {
                CLUser profileEntity = userService.EditAvatar(user);
                return OperResult<CLUser>.Success(profileEntity);
            }
            catch (Exception ex)
            {
                return OperResult<CLUser>.Wrong(ex);
            }
        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public OperResult<CLUser> GetUser(int userId)
        {
            IUserService userService = new UserService();
            CLUser user = userService.FindByUserId(userId);
            return OperResult<CLUser>.Success(user);
        }

      
    }
}
